#include<cstdio>
#include<iostream>
#include<set>
#include<algorithm>
using namespace std;
const int maxn=70000;
struct node
{
	int val,id;
	bool operator<(const node& other)const
	{
		if(other.val==val)return other.id>id;
		else return other.val>val;
	}
};
int main()
{
	set<node>a;
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		node t;
		int x;
		scanf("%d",&x);
		t.val=x;
		t.id=i;
		a.insert(t);
	}
	set<node>::iterator it;
	int Q;
	scanf("%d",&Q);
	for(int i=1;i<=Q;i++)
	{
		int l,r,x;
		scanf("%d%d%d",&l,&r,&x);
		node t;
		t.val=x;t.id=l;
		set<node>::iterator it=a.lower_bound(t);
		if(it->id<=r&&it->val==x)printf("1");
		else printf("0");
	}
	printf("\n");
	return 0;
}



